/**
 * yiqihao(一起好商务股份有限公司) copyright 
 */
package com.p2p.front.task;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.p2p.front.service.RechargeService;


/**
 *
 * @author leiruiqi@yiqihao.com
 *
 * 2015年4月1日 下午3:41:59
 */

@Service("rechargeOverTimeTask")
public class RechargeOverTimeTask extends BaseTask{
	protected final Logger logger = LoggerFactory.getLogger(RechargeOverTimeTask.class);
	
	@Resource
	private RechargeService rechargeService;
	
	@Override
	public String getBizKey() {
		String bizKey = "task_RechargeOverTime_";
		return bizKey;
	}

	@Scheduled( cron="0 0/10 * * * ? ")//每10分钟一次
	public void doUpdateStatusForOverTime(){
		if(!this.doTaskSynchronous(getBizKey(), 20)){
			return;
		}
		logger.info("start Update overtime recharege task");
		try {
			doBiz();
		} catch (Exception e) {
			logger.error("",e);
		}
		logger.info("end Update overtime recharege task");
		this.doRmoveTaskSynchronous(getBizKey());
	}
	
	@Override
	public void doBiz(){
		
		int rows = rechargeService.updateForOverTime();
		logger.info("find and update "+rows+" rows");
	}
}
